package com.ss.android.account.b;

import com.bytedance.common.utility.Logger;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;

public final class Benchmark {
    private static SimpleDateFormat a = new SimpleDateFormat();

    private List b;
    private int c;
    private long d;
    private String e;

    public Benchmark(String arg3) {
        this.e = arg3;
        this.b = new ArrayList();
        this.d = System.currentTimeMillis();
    }

    public final void a() {
        float v14 = 1000f;
        StringBuilder v4 = new StringBuilder();
        if (this.b.size() == 0) {
            Logger.d("Benchmark", "no things are collected");
        } else {
            long v2 = this.d;
            long v6 = ((a) this.b.get(this.b.size() - 1)).a - this.d;
            Iterator v5 = this.b.iterator();
            while (v5.hasNext()) {
                Object v0 = v5.next();
                v4.append("  ").append(String.format("%-" + this.c + "s", ((a) v0).b)).append(": ");
                v2 = ((a) v0).a - v2;
                v4.append(String.format("%8.4f", Float.valueOf((((float) v2)) / v14))).append(" seconds").append(String.format("  %2d%%", Long.valueOf(v2 * 100 / v6))).append("\n");
                v2 = ((a) v0).a;
            }

            v4.insert(0, String.format("benchmark \'%s\' duration: %f seconds, start at: %s\n", this.e, Float.valueOf((((float) v6)) / v14), Benchmark.a.format(new Date(this.d))));
            Logger.d("Benchmark", v4.toString());
        }
    }

    public final void a(String arg3) {
        this.b.add(new a(arg3));
        this.c = Math.max(this.c, arg3.length());
    }

    final class a {
        public long a;
        public String b;

        a(String arg3) {

            this.b = arg3;
            this.a = System.currentTimeMillis();
        }
    }
}

